package com.ddwl.message.domain.sms.dao;

import org.springframework.util.CollectionUtils;
import com.ddwl.common.dao.TkDao;
import com.ddwl.message.domain.sms.dao.mapper.SmsTemplateMapper;
import com.ddwl.message.domain.sms.dao.model.SmsTemplate;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 类LoanSmsTemplateDao.java的实现描述
 *
 * @author zach
 * @Date :2019-05-16 11:29.
 */
@Repository
public class SmsTemplateDao extends TkDao<SmsTemplateMapper, SmsTemplate> {


    /**
     * 根据code查询模板信息
     * @param tempCode
     * @return
     */
    public SmsTemplate selectLoanSmsTemplate(String tempCode){
        Example example = getExample();
        example.and().andEqualTo("code",tempCode);
        List<SmsTemplate> loanSmsTemplateList = baseMapper.selectByExample(example);
        if(CollectionUtils.isEmpty(loanSmsTemplateList)){
            return null;
        }
        return loanSmsTemplateList.get(0);
    }

    public List<SmsTemplate> getEvent() {
       return baseMapper.selectAll();
    }
}
